package org.come.mouslisten;

import com.tool.Document.RichDocument;
import com.tool.btn.MountPanelBtn;
import com.tool.image.ImageMixDeal;
import com.tool.imagemonitor.FightingMonitor;
import com.tool.pet.PetProperty;
import com.tool.role.RoleData;
import com.tool.role.RoleLingFa;
import com.tool.time.Limit;
import com.tool.time.TimeLimit;
import come.tool.Fighting.FightingMixDeal;
import come.tool.JDialog.TiShiUtil;
import come.tool.handle.HandleState;
import org.come.Frame.*;
import org.come.Jpanel.AircraftJPanel;
import org.come.Jpanel.PartnerMainJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.bean.*;
import org.come.entity.Fly;
import org.come.entity.*;
import org.come.good.Box;
import org.come.good.*;
import org.come.model.Configure;
import org.come.model.Lingbao;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.*;
import org.lottery.frame.LotteryMainFrame;
import org.skill.panel.SkillSMGatePanel2;

import javax.swing.*;
import javax.swing.text.BadLocationException;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class LiangHaoMouslisten implements MouseListener {
    private int goodPlace;// 物品的位置
    // 要替换物品的位置
    public static int replace = -1;
    // 正在预备替换的格子位置
    public static int replacepath = -1;
    AthChartJframe athChartJframe;
    public static List<String> list = new ArrayList<>();
    public LiangHaoMouslisten(int goodPlace) {
        super();
        this.goodPlace = goodPlace;
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {
        LiangHaoMouslisten.list.add(this.goodPlace + "");
        Goodstable goodstable = GoodsListFromServerUntil.Getgood(goodPlace);
        if (e.isShiftDown() && e.getButton() == MouseEvent.BUTTON1) {
            if (goodstable != null) {
                try {
                    JTextField SendMes = ZhuFrame.getZhuJpanel().getSendMes();
                    ((RichDocument) SendMes.getDocument()).insertRich(SendMes.getCaretPosition(), 2,
                            goodstable.getRgid(), "[" + goodstable.getGoodsname() + "]", "G", null);
                } catch (BadLocationException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
            return;
        }
        // 右键使用物品
        if (e.getButton() == MouseEvent.BUTTON3) {
            // 判断是否是加锁或者解锁状态
            if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE10)
                    || MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE11)) {
                return;
            }
            // 判断是否处于替换
            if (replace != -1) {// 取消物品替换
                goodreplace(-1, -1);
            } else {// 判断当前物品不为空
                if (goodstable != null) {
                    // 判断物品的使用类型
                    long type = goodstable.getType();
                    // 判断是在战斗中点击还是玩家平时点击 还是召唤兽平时点击
                    if (FightingMixDeal.State != HandleState.USUAL) {
                        if (!GoodsMouslisten.isFightingUse(type)) {
                            return;
                        }
                        int man = -1;
                        if (FightingMixDeal.State == HandleState.HANDLE_PLAYER) {
                            man = FightingMixDeal.myman();
                        } else if (FightingMixDeal.State == HandleState.HANDLE_PET) {
                            man = FightingMixDeal.myman() + 5;
                        }
                        int path = FightingMixDeal.CurrentData(FightingMixDeal.camp, man);
                        if (path != -1 /*&& !FightingMixDeal.CurrentData.get(path).getFightingManData().ztcz("遗忘")*/) {
                            FightingMonitor.mousesname = goodstable.getRgid() + "";
                            MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE9);
                            FightingMonitor.mousestate = 2;
                            ZhuFrame.getZhuJpanel().HideBeastBtn();
                        } else {
                            ZhuFrame.getZhuJpanel().addPrompt("当前状态无法使用药品");
                        }
                        TestpackJframe.getTestpackJframe().getJpac().ClearText();
                        ZhuFrame.getZhuJpanel().cleargoodtext();
                        FormsManagement.HideForm(2);
                    } else {
                        if (Util.isM()) {
                            return;
                        }
                        // /**判断是否解锁*/
                        // if(Util.isCanBuyOrno()){return;}
                        if (ZhuJpanel.getUseGoodsType() == 0) {// 玩家平常点击
                            try {
                                ManNoCombat(goodstable, type);
                            } catch (Exception e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }
                        } else if (ZhuJpanel.getUseGoodsType() == 1) {// 召唤兽物品点击
                            petUseGoods(goodstable, type);
                        } else if (ZhuJpanel.getUseGoodsType() == 2) {// 坐骑喂养点击
                            mountUseGoods(goodstable, type);
                        }
                    }
                }
            }
        } else if (e.getButton() == MouseEvent.BUTTON1) {
            // 左键点击
            // 判断鼠标是否是加锁图标
            if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE10)) {
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
                // 判断物品是否为空
                if (goodstable != null) {
                    if (EquipTool.isEquip(goodstable.getType())) {
                        if (goodstable.getGoodlock() == 1) {
                            ZhuFrame.getZhuJpanel().addPrompt("该物品已加锁");
                        } else {
                            goodstable.setGoodlock(1);
                            gooduse(goodstable, 0);
                            ZhuFrame.getZhuJpanel().addPrompt("加锁成功");
                        }
                    } else {
                        ZhuFrame.getZhuJpanel().addPrompt("该类型物品不可加锁");
                    }
                }
            } else if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE11)) {
                // 判断鼠标是否是解锁图标
                if (goodstable != null) {// 判断物品是否为空//判断物品是否加锁
                    if (goodstable.getGoodlock() == 1) {// 已加锁
                        goodstable.setGoodlock(0);
                        gooduse(goodstable, 0);
                        ZhuFrame.getZhuJpanel().addPrompt("解锁成功");
                        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
                    }
                }
            } else {// 判断是否正在替换
                if (replace != -1) {
                    goodreplace(replace, goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
                } else {
                    if (goodstable != null) {// 判断物品是否为空
                        replacepath = goodPlace;
                        replace = goodPlace + GoodsListFromServerUntil.Pagenumber * 24;
                    }
                }
            }
        }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        LiangHaoMouslisten.list.remove(this.goodPlace + "");
    }

    /**
     * 玩家平常点击物品使用
     *
     * @param goodstable
     * @throws Exception
     */
    public void ManNoCombat(Goodstable goodstable, long type) throws Exception {
        // 使用的物品属于装备
    	int EquipmentType = Goodtype.EquipmentType(type);
        if (EquipmentType != -1) {
            UseEquipment(EquipmentType, goodstable);
        } else if (type == 0) {// 药品使用
            int usetime = goodstable.getUsetime();
            Medicine.RedAndBlue(goodstable, goodstable.getValue());
            if (usetime != goodstable.getUsetime()) {
                LiangHaoMouslisten.gooduse(goodstable, 1);
                String mes = Agreement.getAgreement().rolechangeAgreement(
                        "H" + RoleData.getRoleData().getLoginResult().getHp() + "="
                                + RoleData.getRoleData().getLoginResult().getMp());
                SendMessageUntil.toServer(mes);
                PetAddPointMouslisten.getplayerValue();// 进行面板刷新
                Music.addyinxiao("战斗、站立、行走使用药品.mp3");// 药品使用监听
            }
        } else if (type == 60001 || type == 60002) {// 新手礼包使用
            Box.Novice(goodstable);
        } else if (type == 2114) {// 星梦石使用
            Box.xms(goodstable);
        } else if (type == 2042) {// 蟠桃使用
            Consumptions.Consumption(goodstable, goodstable.getValue());
        } else if (Goodtype.Flightchess(type)) {// 飞行旗使用
            Flight.Flightchess(goodstable, type);
        } else if (type == 188) {// 符石使用
            Lingbaogood.fushi(goodstable, goodPlace);
        } else if (type == 1688 || type == 300 || type == 121 || type == 122 || type == 2121) {// 1688改名卡使用
                                                                               // 300修正卡
                                                                               // 121解禁
                                                                               // 122解封
        																		// 2121点卡充值
            ExchangeAwardJframe.getExchangeAwardJframe().getAwardJpanel().use((type == 1688 ? 0 : type == 300 ? 1 : type == 121 ? 3 : type == 2121 ? 888 : 4), goodstable.getRgid());
        } else if (type == 213) {// 特赦令使用
            Box.tesheling(goodstable);
        } else if (type >= 50 && type <= 61) {// 孩子物品
            BabyGood.BabyGoods(goodstable, type);
        } else if (type == 1003) {// 任务道具使用
            TaskGood.gainTask(goodstable);
        }
        // else if (type == 80156) {// 使用夜明珠（获得物品或触发战斗）
        // usePearl();
        // }
        else if (type == 729) {
            PetEquip.RoleCJS(goodstable);
        } else if (type == 889) { // 通灵宝券
            usePsyVou();
        } else if (type == 60003) {
            LotteryMainFrame.getLotteryMainFrame().getLotteryMainPanel()
                    .getlotteryTypeGoods(Integer.parseInt(goodstable.getValue()));
            return;
        } else if (type == 506) { // 吉祥如意蛋
            NPCJfram.getNpcJfram().getNpcjpanel().openJxryd();
        } else if (type == 190 || type == 891 || type == 1002|| type == 28955) {// 灵宝物品
            Lingbao lingbao = RoleLingFa.getRoleLingFa().getChoseBao();
            if (lingbao == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("你没有选中的灵宝");
                return;
            }
            userling(goodstable, lingbao);
        } else if (type == 520) {
            OptionsJframe.getOptionsJframe().getOptionsJpanel()
                    .showBox(TiShiUtil.starCardDeposit, goodstable, "真的要放入地煞星录吗?");
        } else if (Goodtype.isPalGoods(type)) {// 伙伴物品使用
            PartnerMainJpanel mainJpanel = PartnerJframe.getPartnerJframe().getPartnerMainJpanel();
            if (mainJpanel.getPalDataChooseId() < 0) {
                ZhuFrame.getZhuJpanel().addPrompt2("请选择一个伙伴");
                return;
            }
            Pal pidGetPal = mainJpanel.pidGetPal(mainJpanel.getPalDataChooseId());
            if (pidGetPal == null) {
                return;
            }
            if (goodstable != null) {
                if (goodstable.getType() == 7500) {
                    return;
                }
                String sendmes = Agreement.getAgreement().userpalAgreement(
                        pidGetPal.getId() + "|" + goodstable.getRgid());
                SendMessageUntil.toServer(sendmes);
            }

        } else {
            userRole(goodstable);
        }
        if (goodstable.getUsetime() <= 0) {
            GoodsListFromServerUntil.Delete(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
        }
    }

    /**
     * 装备物品使用
     *
     * @throws Exception
     */
    public void UseEquipment(int EquipmentType, Goodstable goodstable) throws Exception {
        int part = DevicGoodsEquiptmentUntil.getEquiptmentOrNo(goodstable);
        if (part == -2) {
            ZhuFrame.getZhuJpanel().addPrompt2("你达不到装备要求");
            return;
        }
        // 判断装备部位要求
        if (part != -1) {
            EquipmentType = part;
        } else if (EquipmentType == 10) {
            if (GoodsListFromServerUntil.getChoseGoodsList()[EquipmentType] != null) {
                EquipmentType = 11;
            }
        }
        GoodsListFromServerUntil.MutualChange(EquipmentType, goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub鼠标移入
        Goodstable goodstable = GoodsListFromServerUntil.Getgood(goodPlace);
        if (goodstable != null) {
            TestpackJframe.getTestpackJframe().getJpac().PaintingText(goodPlace);
            ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
        }
    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub鼠标离开
        TestpackJframe.getTestpackJframe().getJpac().ClearText();
        ZhuFrame.getZhuJpanel().cleargoodtext();
    }

    public int getGoodPlace() {
        return goodPlace;
    }

    public void setGoodPlace(int goodPlace) {
        this.goodPlace = goodPlace;
    }

    /** 物品替换 one=-1为取消当前替换 */
    public static void goodreplace(int one, int two) {
        if (one != -1) {
            GoodsListFromServerUntil.tihuan(one, two);
        }
        replace = -1;
        replacepath = -1;
    }

    public static GoodsResultArrBean goodarr = new GoodsResultArrBean();

    /** 将单独物品情况返回给服务器 */
    public static void gooduse(Goodstable goodstable, int type) {
        // 0装备或者加锁之类修改 1物品消耗 2超级聚魄丹提取成功 夜明珠 孔明灯 八荒瓶子 元气蛋 召唤兽饰品类 内丹
        goodarr.setI(type);
        goodarr.getList().clear();
        goodarr.getList().add(goodstable);
        String sendmes = Agreement.getAgreement().packchangeAgreement(GsonUtil.getGsonUtil().getgson().toJson(goodarr));
        // 将装备物品返还给客户端// 向服务器发送信息
        SendMessageUntil.toServer(sendmes);
    }

    /** 装备 脱下的放前面 穿上的放前面 */
    public static void gooduse(Goodstable good1, Goodstable good2, int type) {
        // 0装备或者加锁之类修改 1物品消耗 2超级聚魄丹提取成功 夜明珠 孔明灯 八荒瓶子 元气蛋 召唤兽饰品类 内丹
        goodarr.setI(type);
        goodarr.getList().clear();
        if (good1 != null) {
            goodarr.getList().add(good1);
        }
        if (good2 != null) {
            goodarr.getList().add(good2);
        }
        String sendmes = Agreement.getAgreement().packchangeAgreement(GsonUtil.getGsonUtil().getgson().toJson(goodarr));
        // 将装备物品返还给客户端// 向服务器发送信息
        SendMessageUntil.toServer(sendmes);
    }

    /** 召唤兽使用物品的方法 */
    public void petUseGoods(Goodstable goodstable, long type) {
        // 药品使用
        if (Goodtype.FightingMedicine(type)) {
            int usetime = goodstable.getUsetime();
            Medicine.PetRedAndBlue(goodstable, goodstable.getValue());
            if (usetime != goodstable.getUsetime()) {
                LiangHaoMouslisten.gooduse(goodstable, 1);
                if (goodstable.getUsetime() <= 0)
                    GoodsListFromServerUntil.Deletebiaoid(goodstable.getRgid());
                SendRoleAndRolesummingUntil.sendRoleSumming(UserMessUntil.getChosePetMes());
                // 进行面板刷新
                PetAddPointMouslisten.showPetValue();
                Music.addyinxiao("战斗、站立、行走使用药品.mp3");// 药品使用监听
            }
        } else if (type == 750) {// 内丹
            useNedan();
        } else if (type == 2115) {// 混元丹
            hyd(goodstable);
            if (goodstable.getUsetime() <= 0)
                GoodsListFromServerUntil.Deleted(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
        } else if (type == 729 || type == 510 || type == 511 || type == 512) {// 彩晶石使用
            PetEquip.PetCJS(goodstable);
        } else {
            userPet(goodstable, UserMessUntil.getChosePetMes());
        }
    }

    /** 混元丹 */
    public static void hyd(Goodstable goodstable) {
        RoleSummoning pet = UserMessUntil.getChosePetMes();
        int lvl = AnalysisString.petLvlint(pet.getGrade());
        pet.setBone(lvl);
        pet.setSpir(lvl);
        pet.setPower(lvl);
        pet.setSpeed(lvl);
        if (pet.getTurnRount() >= 4) {
            pet.setCalm(lvl);
        }
        ZhuFrame.getZhuJpanel().addPrompt2("你使用了" + goodstable.getGoodsname());
        goodstable.setUsetime(goodstable.getUsetime() - 1);
        LiangHaoMouslisten.gooduse(goodstable, 1);
        PetAddPointMouslisten.showPetValue();
        // 发送消息给服务器
        // 将这个召唤兽发给服务器
        SendRoleAndRolesummingUntil.sendRoleSumming(pet);
    }

    /** 使用内丹的方法 */
    public void useNedan() {
        RoleSummoning pet = UserMessUntil.getChosePetMes();
        if (pet == null) {
            ZhuFrame.getZhuJpanel().addPrompt("请选择召唤兽！");
            return;
        }
        Goodstable good = GoodsListFromServerUntil.Getgood(goodPlace);
        if (good == null) {
            return;
        }
        String[] strings = good.getValue().split("\\|");
        String[] stringLevel = strings[2].split("=");
        String[] stringLevel2 = stringLevel[1].split("转");
        // 内丹转生次数
        int Nedanturn = Integer.parseInt(stringLevel2[0]);
        // 内丹等级
        int Nedanlvl = Integer.parseInt(stringLevel2[1]);
        // 召唤兽转生次数
        int Petturn = pet.getTurnRount();
        // 召唤兽等级
        int Petlvl = AnalysisString.petLvlint(pet.getGrade());
        if (Petturn < Nedanturn || (Petturn == Nedanturn && Petlvl < Nedanlvl)) {
            //转生次数小于内丹转生次数   转生次数等于内丹转生次数
            ZhuFrame.getZhuJpanel().addPrompt2("您的召唤兽等级低于内丹等级！！！");
            return;
        }
        long type2233 = good.getQuality();
        if (type2233 == 2233) {
        	 if (!pet.getSummoningid().equals( "200143")) {  ZhuFrame.getZhuJpanel().addPrompt2("推广宠物专属内丹！！！"); return;}
        }
        String[] goodIds = null;
        if (pet.getInnerGoods() != null && !pet.getInnerGoods().equals("")) {
            goodIds = pet.getInnerGoods().split("\\|");
        }
        StringBuffer buffer = new StringBuffer();
        if (goodIds != null) {
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (goodIds.length >= Integer.parseInt(configure.getNdslsx())) {//召唤兽内丹
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽的内丹已超过上限!");
                return;
            }
            for (int i = 0; i < goodIds.length; i++) {
                if (buffer.length() != 0) {
                    buffer.append("|");
                }
                buffer.append(goodIds[i]);
                Goodstable good2 = GoodsListFromServerUntil.fushis.get(new BigDecimal(goodIds[i]));
                if (good2.getGoodsname().equals(good.getGoodsname())) {
                    ZhuFrame.getZhuJpanel().addPrompt("你已有这种类型的内丹了！");
                    return;
                }
            }
        }
        if (buffer.length() != 0) {
            buffer.append("|");
        }
        buffer.append(good.getRgid());
        pet.setInnerGoods(buffer.toString());
        GoodsListFromServerUntil.fushis.put(good.getRgid(), good);
        // 你已获得了内丹技能
        ZhuFrame.getZhuJpanel().addPrompt("你获得了内丹技能 " + good.getGoodsname());
        // 将这个召唤兽发给服务器
        SendRoleAndRolesummingUntil.sendRoleSumming(pet);
        good.setStatus(1);
        gooduse(good, 0);
        // 将这个物品删除
        GoodsListFromServerUntil.Deleted(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
        // 刷新内丹
        ChangeMouseSymbolMouslisten.refreshNedan(pet);
    }

    /**
     * 坐骑喂养物品的方法
     */
    public void mountUseGoods(Goodstable goodstable, long type) {
        if (MountJframe.getMountjframe().getMountjpanel().getListmount().getSelectedIndex() == -1) {
            return;
        }
        int index = MountJframe.getMountjframe().getMountjpanel().getListmount().getSelectedIndex();
        Mount mount = ZhuJpanel.getListMount().get(index);
        if (type == 718) {// 坐骑技能卡
            useMountSkillCard(mount);
        } else if (type == 719) {// 坐骑遗忘所有技能
            mountMissSkills(mount);
        } else if (type == 720) {// 随机生成坐骑的初始值
            // randomMountValue();
        } else {
            userMount(goodstable, mount);
        }
    }

    /** 使用坐骑技能卡的方法 */
    public void useMountSkillCard(Mount mount) {
    	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
    	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
    	Configure configure = item.get(new BigDecimal(1));
        if (mount.getMountskill().size() >= Integer.parseInt(configure.getZqjnsx()) && mount.getMountid()<8) {// 超过两个
            ZhuFrame.getZhuJpanel().addPrompt("普通坐骑最多可拥有"+Integer.parseInt(configure.getZqjnsx())+"个技能！！！");
            return;
        }else if(mount.getMountskill().size() >= (Integer.parseInt(configure.getZqjnsx())+1) && mount.getMountid()>7) {
        	ZhuFrame.getZhuJpanel().addPrompt("飞行坐骑最多可拥有"+(Integer.parseInt(configure.getZqjnsx())+1)+"个技能");
            return;
        }
        int index = MountJframe.getMountjframe().getMountjpanel().getListmount().getSelectedIndex();
        MountSkill mountSkill = new MountSkill();
        mountSkill.setMid(mount.getMid());
        mountSkill.setSkillname(GoodsListFromServerUntil.Getgood(goodPlace).getGoodsname());
        Boolean bool = false;
        // 先判断这只坐骑之前是否有这个技能
        if (mount.getMountskill().size() != 0) {
            for (int i = 0; i < mount.getMountskill().size(); i++) {
                if (mount.getMountskill().get(i).getSkillname().equals(mountSkill.getSkillname())) {
                    bool = true;
                }
            }
            // 判断这个技能之前是否有
            if (bool) {// 有
                // 提示:该坐骑已有这个技能
                ZhuFrame.getZhuJpanel().addPrompt("该坐骑已有这个技能!");
            } else {// 没有
                // 将这个技能加到该座骑的技能列表中
                mount.getMountskill().add(mountSkill);
                // 发送消息给服务器
                String sendmes = Agreement.getAgreement().addMountSkill(
                        GsonUtil.getGsonUtil().getgson().toJson(mountSkill));
                // 向服务器发送信息
                SendMessageUntil.toServer(sendmes);
                GoodsListFromServerUntil.Getgood(goodPlace).goodxh(1);
                gooduse(GoodsListFromServerUntil.Getgood(goodPlace), 1);
                if (GoodsListFromServerUntil.Getgood(goodPlace).getUsetime() <= 0) {
                    // 将这个物品删除
                    GoodsListFromServerUntil.Deleted(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
                }
                // 刷新坐骑技能面板
                MountPanelBtn.refreshMountSkills(index);
            }
        } else {// 之前没有技能
            // 将这个技能加到该座骑的技能列表中
            ZhuJpanel.getListMount().get(index).getMountskill().add(mountSkill);
            // 发送消息给服务器
            String sendmes = Agreement.getAgreement()
                    .addMountSkill(GsonUtil.getGsonUtil().getgson().toJson(mountSkill));
            // 向服务器发送信息
            SendMessageUntil.toServer(sendmes);
            GoodsListFromServerUntil.Getgood(goodPlace).goodxh(1);
            gooduse(GoodsListFromServerUntil.Getgood(goodPlace), 1);
            if (GoodsListFromServerUntil.Getgood(goodPlace).getUsetime() <= 0) {
                // 将这个物品删除
                GoodsListFromServerUntil.Deleted(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
            }
            // 刷新坐骑技能面板
            MountPanelBtn.refreshMountSkills(index);
        }
        // 给管制的坐骑添加属性
        if (UserMessUntil.getPetListTable() != null && UserMessUntil.getPetListTable().size() > 0) {
            for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                RoleSummoning pet = UserMessUntil.getPetListTable().get(i);
                if (mount.getSid() != null && pet.getSid().compareTo(mount.getSid()) == 0) {
                    ChangeMouseSymbolMouslisten.addProperties(pet, mount);// 给召唤兽添加坐骑技能属性
                } else if (mount.getOthrersid() != null && pet.getSid().compareTo(mount.getOthrersid()) == 0) {
                    ChangeMouseSymbolMouslisten.addProperties(pet, mount);// 给召唤兽添加坐骑技能属性
                } else if (mount.getSid3() != null && pet.getSid().compareTo(mount.getSid3()) == 0) {
                    ChangeMouseSymbolMouslisten.addProperties(pet, mount);// 给召唤兽添加坐骑技能属性
                }
            }
        }
    }

    /** 坐骑遗忘所有技能 */
    public void mountMissSkills(Mount mount) {
        int index = MountJframe.getMountjframe().getMountjpanel().getListmount().getSelectedIndex();
        if (mount.getMountskill().size() != 0) {
            // 给管制的坐骑移除属性
            if (UserMessUntil.getPetListTable() != null && UserMessUntil.getPetListTable().size() > 0) {
                for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                    RoleSummoning pet = UserMessUntil.getPetListTable().get(i);
                    if (mount.getSid() != null && pet.getSid().compareTo(mount.getSid()) == 0) {
                        ChangeMouseSymbolMouslisten.clearPropertie(pet);// 给召唤兽添加坐骑技能属性
                    } else if (mount.getOthrersid() != null && pet.getSid().compareTo(mount.getOthrersid()) == 0) {
                        ChangeMouseSymbolMouslisten.clearPropertie(pet);// 给召唤兽添加坐骑技能属性
                    } else if (mount.getSid3() != null && pet.getSid().compareTo(mount.getSid3()) == 0) {
                        ChangeMouseSymbolMouslisten.clearPropertie(pet);// 给召唤兽添加坐骑技能属性
                    }
                }
            }
            // 清除这只坐骑的技能表
            mount.getMountskill().clear();
            // 发送消息给服务器
            String sendmes = Agreement.getAgreement().missMountSkill(
                    GsonUtil.getGsonUtil().getgson().toJson(mount.getMid()));
            // 向服务器发送信息
            SendMessageUntil.toServer(sendmes);
            // 刷新坐骑技能面板
            MountPanelBtn.refreshMountSkills(index);
            // 清空坐骑技能面板
            MountSkillsJframe.getMountSkillsJframe().getMountSkillsJpanel().getModelskilleffect().removeAllElements();
            // 刷新召唤兽抗性面板
            if (FormsManagement.getframe(58).isVisible()) {
                PetProperty.ShowQl(UserMessUntil.getChosePetMes());
            }
        }
        GoodsListFromServerUntil.Getgood(goodPlace).goodxh(1);
        gooduse(GoodsListFromServerUntil.Getgood(goodPlace), 1);
        if (GoodsListFromServerUntil.Getgood(goodPlace).getUsetime() <= 0) {
            // 将这个物品删除
            GoodsListFromServerUntil.Deleted(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
        }

    }

    /** 使用通灵宝券的方法 */
    public void usePsyVou() {
        // 通灵宝券的数量
        QuackGameJframe.getQuackGameJframe().getGameJpanel().kyNum = GoodsListFromServerUntil.Getgood(goodPlace)
                .getUsetime();
        // 向服务器获取上面一排五个的图片信息
        String sendMes = Agreement.getFiveMsgAgreement("G");
        SendMessageUntil.toServer(sendMes);
    }

    /** 玩家使用物品 */
    public void userRole(Goodstable good) throws Exception {
        // 消耗物品的属性
        Limit limit = new Limit();
        long type = good.getType();
    	if (type == 100 || type == 888 || type == 2041||type==935||type==936||type==951|| type==2126 ) {
            long[] xiaohao = AnalysisString.xiaohao(good.getValue());
            if (xiaohao[0] != 0) {
                if (RoleData.getRoleData().getLoginResult().getGold().longValue() + xiaohao[0] > Util.GoldUP
                        .longValue()) {
                    ZhuFrame.getZhuJpanel().addPrompt2("金钱上限9999.99亿");
                    return;
                }
            }
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        } else if (type == 7005 || type == 118 || type == 2051 || type == 2052 || type == 2057 || type == 1007) {// 获得物品类的
            if (GoodsListFromServerUntil.Surplussum("-1", "-1", 1) == 0) {// 先判断是否还有空闲的格子
                ZhuFrame.getZhuJpanel().addPrompt2("你的背包已满");
                return;
            }
            if (type == 2051 || type == 2052 || type == 2057 || type == 1007) {
                String[] vs = good.getValue().split("\\=");
                if (vs[0].equals("宝图")) {
                    vs = vs[1].split(",");
                    // 地图id 地图名 位置 位置 掉落
                    int mapid = Integer.parseInt(vs[0]);
                    int x = Integer.parseInt(vs[2]) / 20;
                    int y = Integer.parseInt(vs[3]) / 20;
                    if (mapid != Util.ditubianma) {
                        ZhuFrame.getZhuJpanel().addPrompt2("好像不是在这个场景吧");
                        return;
                    }
                    RoleShow roleShow = ImageMixDeal.userimg.getRoleShow();
                    long x2 = roleShow.getX() / 20;
                    long y2 = roleShow.getY() / 20;
                    x -= x2;
                    y -= y2;
                    x = Math.abs(x);
                    y = Math.abs(y);
                    if (x > 4 || y > 4) {
                        ZhuFrame.getZhuJpanel().addPrompt2("坐标不对");
                        return;
                    }
                }
            }
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        } else if (type == 502) {// 召唤兽卡
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
        	
            if (UserMessUntil.getPetListTable() != null && UserMessUntil.getPetListTable().size() >= Integer.parseInt(configure.getXdzhssx())) {
                ZhuFrame.getZhuJpanel().addPrompt2("您的召唤兽可携带的数量已满！！！");
                return;
            }
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        }else if(type == 2122){
        	if (GoodsListFromServerUntil.Surplussum("-1", "-1", 1) == 0) {// 先判断是否还有空闲的格子
                ZhuFrame.getZhuJpanel().addPrompt2("你的背包已满");
                return;
            }
        	String[] vs = good.getValue().split("\\=");
            if (vs[0].equals("宝图")) {
            	vs = vs[1].split(",");
                // 地图id 地图名 位置 位置 掉落
                int mapid = Integer.parseInt(vs[0]);
                int x = Integer.parseInt(vs[2]) / 20;
                int y = Integer.parseInt(vs[3]) / 20;
                if (mapid != Util.ditubianma) {
                    ZhuFrame.getZhuJpanel().addPrompt2("好像不是在这个场景吧");
                    return;
                }
            	AthChartJframe.getAthChartJPanel();
           	 	FormsManagement.showForm(3001);
           	 	LaborRank laborRank = new LaborRank();
                laborRank.setRank(11);
                laborRank.setValue1("");
           	 	AthChartJframe.getAthChartJPanel().showViewData(laborRank);
           	 	String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
           	 	SendMessageUntil.toServer(sendmes);
            	good.goodxh(1);
            }
        }else if(type == 2123){
        	if (GoodsListFromServerUntil.Surplussum("-1", "-1", 1) == 0) {// 先判断是否还有空闲的格子
                ZhuFrame.getZhuJpanel().addPrompt2("你的背包已满");
                return;
            }
            AthChartJframe.getAthChartJPanel();
            if(Util.nums!=0) {
            	ZhuFrame.getZhuJpanel().addPrompt2("抽奖还没有结束，请别着急!");
            	return;
            }
       	 	FormsManagement.showForm(3001);
       	 	LaborRank laborRank = new LaborRank();
            laborRank.setRank(11);
            laborRank.setValue1("");
       	 	AthChartJframe.getAthChartJPanel().showViewData(laborRank);
       	 	String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
       	 	SendMessageUntil.toServer(sendmes);
        	good.goodxh(1);
        }else if(type == 2124){
        	//钥匙 宝箱
        	if (GoodsListFromServerUntil.Surplussum("-1", "-1", 1) == 0) {// 先判断是否还有空闲的格子
                ZhuFrame.getZhuJpanel().addPrompt2("你的背包已满");
                return;
            }
        	boolean falg = GoodsListFromServerUntil.isgood(80659,1);
        	if(falg) {
//        		for(Goodstable goodstable:GoodsListFromServerUntil.getGoodslist()) {
//        			if(goodstable!=null) {
//        				if(goodstable.getGoodsid()!=null) {
//        					if(goodstable.getGoodsid().toString().equals("80659")) {
//        						goodstable.goodxh(1);
//        						break;
//        					}
//        				}
//        			}
//        		}
        		GoodsListFromServerUntil.consume(80659, 1);
        		String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
        		SendMessageUntil.toServer(sendmes);
        		good.goodxh(1);
        	}else {
	    		 ZhuFrame.getZhuJpanel().addPrompt2("金钥匙不足！");
	             return;
        	}
        }

    	else if (type == 717) {// 坐骑卡
            int lvl = Integer.parseInt(good.getValue()) / 100;
            if (lvl <= 12) {
                if (ZhuJpanel.getListMount() != null && ZhuJpanel.getListMount().size() != 0) {
                    for (int i = ZhuJpanel.getListMount().size() - 1; i >= 0; i--) {
                        Mount mount = ZhuJpanel.getListMount().get(i);
                        if (mount.getMountid() == lvl) {
                            ZhuFrame.getZhuJpanel().addPrompt("你已有这种坐骑！");
                            return;
                        }
                    }
                }
                String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
                SendMessageUntil.toServer(sendmes);
                good.goodxh(1);
            }
        } else if(type==2235){//飞行器卡
            String[] vs = good.getValue().split("\\=");
            String flyId=vs[2];
    	    if (ZhuJpanel.getListFly()!=null&&ZhuJpanel.getListFly().size()!=0){
	            for(int i=ZhuJpanel.getListFly().size()-1;i>=0;i--){
	                Fly fly=ZhuJpanel.getListFly().get(i);
                    if (fly.getFlytid().toString().equals(flyId)){//修复飞行器重复使用
	                    ZhuFrame.getZhuJpanel().addPrompt("你已有这种飞行器");
	                    return;
                    }
                }
            }
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);

        }else if (type == 2525) {// 挑战卡
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        }else if (type == 66668 || type == 66669) {// 月卡
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        } else if (type == 924) {// 双倍药水
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        }else if (type == 926) {// 技能卡
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        } else if (Goodtype.TimingGood(type) ||Goodtype.Medicine(type) || Goodtype.BlueBack(type)|| type == 88 || type == 99 || type == 111
                || type == 112 || type == 113) {// 时效类相关物品
            limit=TimeLimit.getLimits().getLimit("强法型");
            if (good.getGoodsname().equals("复活符文")) {
                if (limit != null && limit.getName().equals(good.getGoodsname())) {
                    ZhuFrame.getZhuJpanel().addPrompt("你已拥有此效果不可继续使用");
                    return;
                }
            }
            good.goodxh(1);
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
        }else if (type == 66666) {// 神行符
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        } else if (type == 1006) {// 徽章使用
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        }else if (type == 6699) {//包裹扩展卡
            LoginResult loginResult = RoleData.getRoleData().getLoginResult();
            int attachPack = loginResult.getAttachPack();
            if (attachPack >= 2) {
                ZhuFrame.getZhuJpanel().addPrompt2(good.getGoodsname() + "最多只能使用两次");
                return;
            }
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
            loginResult.setAttachPack(++attachPack);
            GoodsListFromServerUntil.GoodExpansion(loginResult.getTurnAround() , loginResult.getAttachPack());
        }else if(type == 9002) { //法门修炼丹
            if (!AnalysisString.lvlfull(ImageMixDeal.userimg.getRoleShow().getGrade(), "1转120")) {
                ZhuFrame.getZhuJpanel().addPrompt2("飞升后才能学习法门");
                return;
            }
            LoginResult loginResult = RoleData.getRoleData().getLoginResult();
            if (loginResult.getFmsld()>10000) {
                ZhuFrame.getZhuJpanel().addPrompt2("法门熟练度已满");
                return;
            }
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
            loginResult.setFmsld(loginResult.getFmsld()+20);
            SkillSMGatePanel2.getSkillValue()[0].setText(loginResult.getFmsld()+"/10000");
            SkillSMGatePanel2.getSkillValue()[1].setText(loginResult.getFmsld()+"/10000");
            SkillSMGatePanel2.getSkillValue()[2].setText(loginResult.getFmsld()+"/10000");
            SkillSMGatePanel2.getSkillValue()[3].setText(loginResult.getFmsld()+"/10000");
            SkillSMGatePanel2.getSkillValue()[4].setText(loginResult.getFmsld()+"/10000");
            SkillSMGatePanel2.getSkillValue()[5].setText(loginResult.getFmsld()+"/10000");
            ZhuFrame.getZhuJpanel().addPrompt2("法门熟练度+20");
        }else if(type == 2120) { 
        	LoginResult loginResult = RoleData.getRoleData().getLoginResult();
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));

        	if(loginResult.getGradeincrease()!=null) {
        		if(loginResult.getGradeincrease()>=Integer.parseInt(configure.getRwdjsx())){
        			ZhuFrame.getZhuJpanel().addPrompt2("等级突破丹最大可服用#G"+configure.getRwdjsx()+"#Y次！#R您已达到上限！");
        			return;
        		}
        	}
        	if(loginResult.getGradeincrease()==null) {
        		loginResult.setGradeincrease(0);
        	}
        	loginResult.setGradeincrease(loginResult.getGradeincrease()+1);
        	good.goodxh(1);
        	String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
        }else if(type == 2233){//月饼
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
        }else if(type == 2250){
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            //good.goodxh(1);
        }else if(type == 2251){
            FormsManagement.HideForm(639);
            LotteryFromServerUntil.drop();
            FormsManagement.showForm(639);
            String sendmes = Agreement.getAgreement().userAgreement(good.getRgid().toString());
            SendMessageUntil.toServer(sendmes);
            good.goodxh(1);
            LotteryFromServerUntil.setHasStart(false);
        }
    }

    /** 召唤兽使用物品 */
    public void userPet(Goodstable good, RoleSummoning pet) {
        if (pet == null) {
            ZhuFrame.getZhuJpanel().addPrompt2("请选择召唤兽！");
            return;
        }
        long type = good.getType();
        if (type == 715) {// 亲密丹
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (pet.getFriendliness() >= Integer.parseInt(configure.getZhsqmsx())) {
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽的亲密值已满！");
                return;
            }
        } else if (type == 503 || type == 2326) {// 召唤兽技能书
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            String petskill = pet.getPetSkills();
            int sum = pet.getOpenSeal();
            if (sum > 0 && petskill != null && !petskill.equals("")) {
                String[] vs = petskill.split("\\|");
                if (vs.length >= (Integer.parseInt(configure.getZhsjngs())-1) || sum <= vs.length) {
                    ZhuFrame.getZhuJpanel().addPrompt2("召唤兽技能格子已经满了");
                    return; 
                }
            }
        } else if (type == 504) {// 聚魄丹
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
        	int skllNum = Integer.parseInt(configure.getZhsjngs());
        	if(skllNum == 5) {
        		int flag = skllNum-1;
        		// 先判断这只召唤兽是否是神兽
        		if (pet.getSsn().equals("2") || pet.getSsn().equals("3") || pet.getSsn().equals("4")) {
        			flag = skllNum;
        		}
        		if (pet.getOpenSeal() >= flag) {
        			ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽的技能封印都已解开！");
        			return;
        		}
        	}else if(skllNum == 7) {
        		int flag = skllNum-1;
        		// 先判断这只召唤兽是否是神兽
        		if (pet.getSsn().equals("2") || pet.getSsn().equals("3") || pet.getSsn().equals("4")) {
        			flag = skllNum;
        		}
        		if (pet.getOpenSeal() >= flag) {
        			ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽的技能封印都已解开！");
        			return;
        		}
        	}else {
        		if (pet.getOpenSeal() >= 6) {
        			ZhuFrame.getZhuJpanel().addPrompt2("普通聚魄丹无法开启更高的技能格");
        			return;
        		}
        	}

        } else if (type == 10086) {//技能丹
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
        	int skllNum = Integer.parseInt(configure.getZhsjngs());
        	if(skllNum == 7) {
        		ZhuFrame.getZhuJpanel().addPrompt2("暂未开启！");
    			return;
        	}else {
        		int flag = 8;
        		if (pet.getSsn().equals("2") || pet.getSsn().equals("3") || pet.getSsn().equals("4")) {
        			flag = 9;
        		}
        		if (pet.getOpenSeal() < 6){
        			ZhuFrame.getZhuJpanel().addPrompt2("高级聚魄丹适合更高的技能格！");
        			return;
        		}
        		
        		if (pet.getOpenSeal() >= flag) {
        			ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽的技能封印都已解开！");
        			return;
        		}
        	}
        } else if (type == 938) {
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
        	int skllNum = Integer.parseInt(configure.getZhsjngs());
        	if(skllNum == 7) {
        		ZhuFrame.getZhuJpanel().addPrompt2("暂未开启！");
    			return;
        	}
            int flag = 6;
            if (pet.getOpenql() >= flag) {
                ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽的启灵技能格子都已解开！");
                return;
            }
        } else if (type == 939) {
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
        	int skllNum = Integer.parseInt(configure.getZhsjngs());
        	if(skllNum == 7) {
        		ZhuFrame.getZhuJpanel().addPrompt2("暂未开启！");
    			return;
        	}
            String value = pet.getPetQlSkills();
            int sum = pet.getOpenql();
            if (sum > 0 && value != null && !value.equals("")) {
                String[] vs = value.split("\\|");
                if (vs.length >= 6 || sum <= vs.length) {
                    ZhuFrame.getZhuJpanel().addPrompt2("召唤兽启灵技能格子已经满了");
                    return;
                }
            }
        }
        else if (type == 2040) {// 召唤兽经验丹

        } else if (type == 2043) {// 九转
            if (pet.getGrade() > 100) {
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽等级过高！");
                return;
            }
        } else if (type == 2113) {// 龙骨
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (pet.getDragon() >= Integer.parseInt(configure.getLzgsx())) {// 不超过3个
                ZhuFrame.getZhuJpanel().addPrompt2("龙骨数量已达到上限！");
                return;
            }
        } else if (type == 918) {// 超级龙骨
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (pet.getSpdragon() >= Integer.parseInt(configure.getCjlzgsx())) {// 不超过3个
                ZhuFrame.getZhuJpanel().addPrompt2("超级龙之骨数量已达到上限！");
                return;
            }
        }else if (type == 716) {// 超级元气丹
//        	if (pet.getSsn().equals("2")) {
//                ZhuFrame.getZhuJpanel().addPrompt2("神兽不可以使用超级元气丹！");
//                return;
//            }
            String value = good.getValue();
            if (value == null || value.equals(""))
                value = "100|0";
            String[] v = value.split("\\|");
            if (v[1].equals("0") || v[1].equals(pet.getSummoningid())) {
                if (good.getGoodsname().indexOf("元气") == -1) {
                    if (pet.getSsn().equals("6")) {
                        ZhuFrame.getZhuJpanel().addPrompt2("不能吃变色丹");
                        return;
                    }
                }
            } else {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽无法使用该类型的元气丹");
                return;
            }
        } else if (type == 192) {// 龙涎丸
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (pet.getSsn().equals("5") || pet.getSummoningid().equals("200125")) {
                int drac = pet.getDraC();
                if (drac >= Integer.parseInt(configure.getLywsx())) {
                    ZhuFrame.getZhuJpanel().addPrompt2("已经达到最大使用次数");
                    return;
                }
                int maxsum = 0;
                if (pet.getGrade() >= 433) {
                    maxsum = 9;
                } else if (pet.getGrade() >= 362) {
                    maxsum = 8;
                } else if (pet.getGrade() >= 322) {
                    maxsum = 7;
                } else if (pet.getGrade() >= 272) {
                    maxsum = 6;
                } else if (pet.getGrade() >= 221) {
                    maxsum = 5;
                } else if (pet.getGrade() >= 191) {
                    maxsum = 4;
                } else if (pet.getGrade() >= 151) {
                    maxsum = 3;
                } else if (pet.getGrade() >= 90) {
                    maxsum = 2;
                } else if (pet.getGrade() >= 50) {
                    maxsum = 1;
                }
                if(pet.getGrade() >= 433) {
                	maxsum = Integer.parseInt(configure.getLywsx());
                }
                if (drac >= maxsum) {
                    String tsm = "召唤兽当前等级最多使用" + maxsum + "个";
                    ZhuFrame.getZhuJpanel().addPrompt2(tsm);
                    return;
                }
            } else {
                ZhuFrame.getZhuJpanel().addPrompt2("不是龙涎丸宝宝");
                return;
            }
        } else if (type == 667) {// 伐骨洗髓丹
            if (pet.getDragon() <= 0) {
                ZhuFrame.getZhuJpanel().addPrompt("召唤兽没有服用过龙骨！！");
                return;
            } 
        } else if (type == 919) {// 伐骨洗髓丹
           if (pet.getSpdragon() <= 0) {
                ZhuFrame.getZhuJpanel().addPrompt("召唤兽没有服用过超级龙之骨头！！");
                return;
            }
        }  else if (type == 2323) {// 终极培养丹
            if (pet.getPetSkills().indexOf("3034") == -1) {
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽没有???");
                return;
            }
        }  else if (type == 2423) {// 终极培养丹
            if (pet.getPetSkills().indexOf("3034") == -1) {
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽没有???");
                return;
            }
        } else if (type == 925) {// 终极技能重修书
            if (pet.getPetSkills() == null || pet.getPetSkills().equals("")) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽没有技能");
                return;
            }
        } else if (type == 2325) {// 超级聚魄丹
            if (pet.getTurnRount() < 3) {// 判断是否为三转召唤兽
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽未3转！");
                return;
            }
            if (pet.getPetSkills() == null || pet.getPetSkills().equals("")) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽没有技能");
                return;
            }
            if (pet.getPetSkills().equals("1828") || pet.getPetSkills().equals("1840")
                    || pet.getPetSkills().equals("1841") || pet.getPetSkills().equals("1842")
                    || pet.getPetSkills().equals("1606") || pet.getPetSkills().equals("1607")
                    || pet.getPetSkills().equals("1608") || pet.getPetSkills().equals("1609")
                    || pet.getPetSkills().equals("1829") || pet.getPetSkills().equals("1830")
                    || pet.getPetSkills().equals("1867") || pet.getPetSkills().equals("1868")
                    || pet.getPetSkills().equals("1869")) {
                ZhuFrame.getZhuJpanel().addPrompt2("该技能不能被提取");
                return;
            }
            if (pet.getGoods() != null) {
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽携带着装备");
                return;
            }
            if (ZhuJpanel.getPetMount(pet.getSid()) != null) {
                ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽被管制中！！！");
                return;
            }
            if (RoleData.getRoleData().getLoginResult().getSummoning_id() != null) {
                if (RoleData.getRoleData().getLoginResult().getSummoning_id().compareTo(pet.getSid()) == 0) {
                    ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽已在参战中！！！");
                    return;
                }
            }
        } else if (type == 727) {// 化形丹神
            int petid = Integer.parseInt(pet.getSummoningid());
            if (petid != 200123 && petid != 200116 && petid != 200117 && petid != 200097 && petid != 200098 && petid != 200099
                    && petid != 200100 && petid != 200101 && petid != 200188 && petid != 200185 && petid != 200184 && petid != 200195 && petid != 200106
                    && petid != 200190 && petid != 200189) {
                String msg = "召唤兽不能使用此化形丹·神";
                ZhuFrame.getZhuJpanel().addPrompt2(msg);
                return;
            }
        } else if (type == 8828) {// 化形丹幻
            int petid = Integer.parseInt(pet.getSummoningid());
            if (petid != 200090 && petid != 200077 && petid != 200085 && petid != 200093 && petid != 200147 && petid != 200135
                    && petid != 200193 && petid != 200158 && petid != 200187 && petid != 200143) {
                String msg = "召唤兽不能使用此化形丹·幻";
                ZhuFrame.getZhuJpanel().addPrompt2(msg);
                return;
            }
        } else if (type == 2116) {// 神兽飞升丹
//            if (!pet.getSsn().equals("2") && !pet.getSsn().equals("3") && !pet.getSsn().equals("4")) {
//                ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽不能使用神兽飞升丹!!!");
//                return;
//            }
            ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (pet.getFlyupNum() >= Integer.parseInt(configure.getSsfsdsx())) {
                ZhuFrame.getZhuJpanel().addPrompt2("神兽 " + pet.getSummoningname() + "的飞升次数已达到上限！");
                return;
            }
        } else if (type == 2118) {// 成长进阶丹
//            if (!pet.getSsn().equals("2") || !pet.getSsn().equals("3") || !pet.getSsn().equals("4")) {
//                ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽不能使用成长进阶丹!!!");
//                return;
//            }
            if (pet.getCzjjd() >= 200) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽 " + pet.getSummoningname() + "的成长进阶丹已达到上限！");
                return;
            }
        } else if (type == 2119) {// 召唤兽变形卡
//        	if (pet.getSsn().equals("2") || pet.getSsn().equals("3") || pet.getSsn().equals("4")) {
//                ZhuFrame.getZhuJpanel().addPrompt2("这只召唤兽不能使用变形卡!!!");
//                return;
//            }
        } else if (type == 1005) {// 枯荣丹

        }else if (type == 8002) {// 神兽飞升丹
            String value = good.getValue();

            String[] value1=value.split("=");
            String value2="0";
            if (value1[1].equals("高级分裂攻击")) {
                value2 = "1833";
            }else if(value1[1].equals("春风佛面")) {
                value2 = "1871";
            }else if(value1[1].equals("春意盎然")) {
                value2 = "1612";
            }else if(value1[1].equals("分花拂柳")) {
                value2 = "1831";
            }else if(value1[1].equals("悬刃")) {
                value2 = "1834";
            }else if(value1[1].equals("遗患")) {
                value2 = "1836";
            }else if(value1[1].equals("报复")) {
                value2 = "1835";
            }else if(value1[1].equals("吉人天相")) {
                value2 = "1838";
            }else if(value1[1].equals("妙手回春")) {
                value2 = "1611";
            }else if(value1[1].equals("视死如归")) {
                value2 = "1872";
            }else if(value1[1].equals("天地同寿")) {
                value2 = "1880";
            }else if(value1[1].equals("扶伤")) {
                value2 = "1858";
            }else if(value1[1].equals("福禄双全")) {
                value2 = "1873";
            }else if(value1[1].equals("炊金馔玉")) {
                value2 = "1600";
            }else if(value1[1].equals("枯木逢春")) {
                value2 = "1601";
            }else if(value1[1].equals("西天净土")) {
                value2 = "1602";
            }else if(value1[1].equals("如人饮水")) {
                value2 = "1603";
            }else if(value1[1].equals("风火燎原")) {
                value2 = "1604";
            }else if(value1[1].equals("高级清明术")) {
                value2 = "1850";
            }else if(value1[1].equals("高级脱困术")) {
                value2 = "1852";
            }else if(value1[1].equals("高级强心术")) {
                value2 = "1854";
            }else if(value1[1].equals("舍身取义")) {
                value2 = "1839";
            }else {
                ZhuFrame.getZhuJpanel().addPrompt("获取技能错误");
                return;
            }

            //	if
            //if (pet.getPetSkillswl().indexOf(value1[0]) == -1) {
            //	ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽没有"+value1[0]);
            //	return;
            //}else
            if (pet.getPetSkills() == null || pet.getPetSkills().equals("")) {
                ZhuFrame.getZhuJpanel().addPrompt2("召唤兽没有技能");
                return;
            }
            if (pet.getPetSkills().indexOf(value2) == -1) {
                ZhuFrame.getZhuJpanel().addPrompt2("该召唤兽没有"+value1[1]);
                return;
            }
        }else if(type == 2234){//召唤兽属性
            //限制条件
            GoodsListFromServerUntil.Getgood(goodPlace).goodxh(1);
            if (GoodsListFromServerUntil.Getgood(goodPlace).getUsetime() <= 0) {
                GoodsListFromServerUntil.Deleted(goodPlace + GoodsListFromServerUntil.Pagenumber * 24);
            }

        } else {
            return;
        }
        String sendmes = Agreement.getAgreement().userpetAgreement(good.getRgid().toString() + "|" + pet.getSid());
        SendMessageUntil.toServer(sendmes);
    }

    /** 坐骑使用物品 */
    public void userMount(Goodstable good, Mount mount) {
        long type = good.getType();
        if (type == 721) {// 坐骑的灵性,力量,根骨各加一
        	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        	Configure configure = item.get(new BigDecimal(1));
            if (mount.getUseNumber() >= Integer.parseInt(configure.getJgtqwsx())) {// 超过3次
                ZhuFrame.getZhuJpanel().addPrompt2("只能使用"+Integer.parseInt(configure.getJgtqwsx())+"次筋骨提气丹");
                return;
            }
        } else if (type == 801) {// 增加坐骑的经验
            int lvl = mount.getMountlvl();
            if (lvl == 100 || lvl >= 200) {// 达到最高等级
                ZhuFrame.getZhuJpanel().addPrompt2("坐骑" + mount.getMountname() + "已达最高等级100级！！");
                return;
            }
        } else if (type == 802) {// 增加坐骑的技能熟练度
            int up = 100000;
            if (mount.getMountlvl() > 100) {
            	ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
            	Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
            	Configure configure = item.get(new BigDecimal(1));
                up = Integer.parseInt(configure.getZqsld());
            }
            if (mount.getProficiency() >= up) {// 达到峰值
                ZhuFrame.getZhuJpanel().addPrompt2("坐骑" + mount.getMountname() + "的技能熟练度已达到峰值！！");
                return;
            }
        } else if (type == 2127 || type == 2128 || type == 2129) {//飞行坐骑移动速度
            
        } else {
            return;
        }
        String sendmes = Agreement.getAgreement().usermountAgreement(good.getRgid().toString() + "|" + mount.getMid());
        SendMessageUntil.toServer(sendmes);
    }

    /** 灵宝使用物品 */
    public void userling(Goodstable good, Lingbao lingbao) {
        long type = good.getType();
        if (type == 190) {// 灵宝技能书
            if (lingbao.getBaotype().equals("法宝")) {
                ZhuFrame.getZhuJpanel().addPrompt2("法宝不能打技能");
                return;
            }
        } else if (type == 891) {// 灵宝诸天印
            int pz = RoleLingFa.getQv(lingbao.getBaoquality());
            if (pz == 50) {
                ZhuFrame.getZhuJpanel().addPrompt2("已经达到最高品质了");
                return;
            }
            pz /= 10;
            pz++;
            int sum = 1;
            switch (pz) {
            case 2:
                sum = 1;
                break;
            case 3:
                sum = 2;
                break;
            case 4:
                sum = 4;
                break;
            case 5:
                sum = 10;
                break;
            }
            // 判断数量是否足够
            if (good.getUsetime() < sum) {
                ZhuFrame.getZhuJpanel().addPrompt2("该品质提升需要消耗" + sum + "个灵宝诸天印");
                return;
            }
        } else if (type == 1002) {// 灵宝经验丹

        }else if (type == 28955) {// 灵宝契合丹

        } else {
            return;
        }
        String sendmes = Agreement.getAgreement().userlingAgreement(
                good.getRgid().toString() + "|" + lingbao.getBaoid());
        SendMessageUntil.toServer(sendmes);
    }


    /** 使用夜明珠 */
    // public void usePearl() {
    // // 获取人物信息
    // LoginResult roleInfo = ImageMixDeal.userimg.getLoginResult();
    // // 判断是否在开放时间
    // Tasktemplate gettask = UserMessUntil.gettask("龙宫寻宝");
    // if (!CreateTask.inTime(gettask.getStartTime(), gettask.getEndTime(),
    // gettask.getWeek()))
    // return;
    // // 判断是否够人数
    // if (roleInfo.getTeamInfo() == null || roleInfo.getTeamInfo().equals("")
    // || roleInfo.getTeamInfo().split("\\|").length < gettask.getTeamSum()) {
    // ZhuFrame.getZhuJpanel().addPrompt2("队伍人数不够" + gettask.getTeamSum() +
    // "个人,先凑齐人数在来吧");
    // return;
    // }
    // // 判断是否在龙宫地图
    // if (roleInfo.getMapid() != 1244) {
    // ZhuFrame.getZhuJpanel().addPrompt2("该地图无法使用！");
    // } else {
    // // 获取物品值(耐久=10，drop类型)
    // String value = GoodsListFromServerUntil.Getgood(goodPlace).getValue();
    // // 获取掉落表
    // Dorp dorp = UserMessUntil.getDorp(value.split(",")[1]);
    // // 拆分值获得战斗和物品
    // String[] values = dorp.getDorpValue().split("\\|");
    // // 获得战斗和概率
    // String[] fight = values[0].split("=")[1].split("&");
    // Integer frist = Integer.parseInt(fight[0].split("\\$")[1]);
    // String dropFrist = fight[0].split("\\$")[0];
    // Integer second = Integer.parseInt(fight[1].split("\\$")[1]);
    // String dropSecond = fight[1].split("\\$")[0];
    // // 判断哪一场战斗
    // Integer flag = Util.random.nextInt(100);
    // String robotID = flag < frist ? dropFrist : flag < (frist + second) ?
    // dropSecond : null;
    // // 概率控制战斗或直接获得物品
    // if (robotID != null) {// 战斗
    // chanceFight(robotID);
    // } else {// 获得物品
    // // String goods =
    // // SureGoodsMes.getGoods(values[1].split("=")[1]);
    // // String[] get = goods.split("\\|");
    // // Goodstable goodstable = UserMessUntil.getgoodstable(new
    // // BigDecimal(get[0]));
    // // goodstable.setUsetime(Integer.parseInt(get[1]));
    // // Goodstable good2 =
    // // GoodsListFromServerUntil.advanceGood(goodstable);
    // // if (good2 == null) {
    // // ZhuFrame.getZhuJpanel().addPrompt2("格子已经满了丢弃物品");
    // // } else if (good2 != goodstable) {
    // // ZhuFrame.getZhuJpanel().addPrompt2("你获得" +
    // // goodstable.getUsetime() + "个" + goodstable.getGoodsname());
    // // }
    // }
    // // 扣除物品耐久度
    // String wear =
    // GoodsListFromServerUntil.Getgood(goodPlace).getValue().split(",")[0].split("=")[1];
    // String newWear = (Integer.parseInt(wear) - 1) + "";
    // // 修改耐久度
    // GoodsListFromServerUntil.Getgood(goodPlace).setValue(GoodsListFromServerUntil.Getgood(goodPlace).getValue().split(",")[0].split("=")[0]
    // + "=" + newWear + "," +
    // GoodsListFromServerUntil.Getgood(goodPlace).getValue().split(",")[1]);
    // // 如果耐久度等于0删除
    // if (Integer.parseInt(newWear) <= 0) {
    // GoodsListFromServerUntil.Getgood(goodPlace).setUsetime((GoodsListFromServerUntil.Getgood(goodPlace).getUsetime()
    // - 1));
    // }
    // // 修改物品
    // gooduse(GoodsListFromServerUntil.Getgood(goodPlace), 2);
    // if (GoodsListFromServerUntil.Getgood(goodPlace).getUsetime() <= 0) {
    //
    // // 将这个物品删除
    // GoodsListFromServerUntil.Deleted(goodPlace +
    // GoodsListFromServerUntil.Pagenumber * 24);
    // }
    // }
    // }
    // 触发战斗
    // public void chanceFight(String robotID) {
    // // 获取人物信息
    // LoginResult roleInfo = ImageMixDeal.userimg.getLoginResult();
    // // 战斗
    // FightingForesee fightingForesee = new FightingForesee();
    // fightingForesee.setRobotid(robotID);
    // if (roleInfo.getTeamInfo() != null && !roleInfo.getTeamInfo().equals(""))
    // {
    // fightingForesee.setYidui(roleInfo.getTeamInfo());
    // } else {
    // fightingForesee.setYidui(roleInfo.getRolename());
    // }
    // try {
    // fightingForesee.setMaxlvl(Creeps.maxGrade());
    // if (fightingForesee.getMaxlvl() < 60) {
    // fightingForesee.setMaxlvl(60);
    // }
    // fightingForesee.setType(1);
    // roleInfo.getPlayer_Paths().clear();
    // String sendMes =
    // Agreement.FightingForeseeAgreement(GsonUtil.getGsonUtil().getgson().toJson(fightingForesee));
    // SendMessageUntil.toServer(sendMes);
    // } catch (Exception e) {
    // // TODO: handle exception
    // e.printStackTrace();
    // }
    //
    /**飞行器使用物品*/
    public static void useFly(Goodstable good, Fly fly){
        long type=good.getType();
        if (type==1101){//飞行器经验
            int lvl=fly.getFlylvl();
            int stat=fly.getFlystate();
            if (lvl>=100){//到达最高级
                ZhuFrame.getZhuJpanel().addPrompt2("飞行器"+fly.getFlyname()+"已达到最高级！");
                return;
            }else{
                if (stat>=5){
                    ZhuFrame.getZhuJpanel().addPrompt2("飞行器#G【"+fly.getFlyname()+"】#Y已达到最高阶#G"+ AircraftJPanel.getJieshu(fly.getFlystate())+"#Y阶！");
                    return;
                }
            }
            if (type==1002){
                if (lvl!=100)
                    ZhuFrame.getZhuJpanel().addPrompt2("飞行器"+fly.getFlyname()+"等级不足");
                return;
            }
        }
        String sendmes = Agreement.getAgreement().useflyAgreement(good.getRgid().toString() + "|" + fly.getMid());
        SendMessageUntil.toServer(sendmes);

    }
}

